{extend name="public/layout" /}
{block name="head"}
<style>
  .tab-content{
    padding:0!important;
  }
</style>
{/block}
{block name="body"}

<body>
<div class="container-fluid p-t-15">
  <div class="card">
    <div class="tab-content">
      <div class="tab-pane active">
        <div class="card-header card-header-sm">
          <form id="search-form" class="form-inline">
            <div class="form-group">
              <div class="input-group">
                <span class="input-group-addon">会员名称</span>
                <input type="text" class="form-control" name="nick@like" />
              </div>
            </div>
            <button type="button" onclick="helper.refreshTable()" id="search-btn" class="btn btn-default">
              <i class="mdi mdi-magnify"></i> 搜索
            </button>
          </form>
        </div>
        <div class="card-body p-lr-15">
          <div class="toolbar">
            <a href="javascript:void(0);" class="btn btn-default" onclick="doAction.add();">
              <i class="mdi mdi-plus"></i> 添加</a>
            <a href="javascript:void(0);" class="btn btn-default" onclick="doAction.del();">
              <i class="mdi mdi-archive"></i> 删除</a>
          </div>
          <div class="table-responsive">
            <table id="grid" class="table"></table>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<script>
  helper.bootstrapTable({
    url: 'index.html',
    columns: [
      {field: "checkbox", checkbox: true},
      {field: "id", title: "#", width: 50, sortable: true},
      {field: "nick", title: "名称", width:50},
      {field: "mobile", width: 100, title: "手机号"},
        {field: "unionid", width: 100, title: "唯一ID"},
      {field: "create_time", title: "创建时间", width:180},
      {
        field: "operate", title: "操作", width: "160",
        formatter: function (value, row, index) {
          var html = '';
          html += '<a href="javascript:void(0);"  class="btn-xs btn btn-primary" onclick="doAction.edit(' + row.id + ')">' +
                  '<i class="mdi mdi-pencil"></i> 编辑</a> ';
          html += '<a href="javascript:void(0);"  class="btn-xs btn btn-danger" onclick="doAction.del(' + row.id + ')">' +
                  '<i class="mdi mdi-archive"></i> 删除</a> ';
          return html;
        }
      },
    ]
  });

  var doAction = {
    add: function () {
      // var room_id = $('#room').val();
      helper.createTab({
        title: '添加商品',
        url: '/system/member/add.html'
      });
    },
    edit: function (id) {
      helper.createTab({
        title: '编辑商品',
        url: '/system/member/edit.html?id=' + id
      });
    },
    del: function (id) {
      var ids = id;
      if (valid.isEmpty(id)) {
        ids = $.map($('#grid').bootstrapTable('getSelections'), function (row, index) {
          return row.id;
        });
        if (ids.length == 0) {
          layer.msg('请选择删除内容');
          return false;
        }
        ids = ids.join(',');
      }
      layer.confirm("确认删除该内容吗?", {icon: 3}, function (index) {
        helper.getAjax({
          url: "/system/live.room/del.html",
          data: {id: ids},
          success: function (res) {
            if (res.code == 1) {
              helper.refreshTable();
            } else {
              helper.tips(res.msg);
            }
          }
        });
        layer.close(index);
      });
    }
  };
</script>
</body>
{/block}